package com.nbgroup.controller;

import com.nbgroup.pojo.common.LoginInfo;
import com.nbgroup.pojo.vo.GetInfoVO;
import com.nbgroup.pojo.vo.LoginVO;
import com.nbgroup.pojo.vo.LogoutVO;
import com.nbgroup.service.LoginService;
import com.nbgroup.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;



@RestController
@Slf4j
public class LoginController {

    @Autowired
    private LoginService loginService;
    @PostMapping("/login")
    public LoginVO login(@RequestBody LoginInfo loginInfo) {
        log.info("登录");
       LoginVO loginVO = loginService.login(loginInfo);
        return loginVO;
    }


    @GetMapping("/getInfo")
    public GetInfoVO getUserInfo(){
        GetInfoVO getInfoVO=loginService.getInfo();
    	return getInfoVO;
    }

    /**
     * 退出
     */
    @PostMapping("/logout")
    public LogoutVO logout() {
        return new LogoutVO("退出成功",200);
    }
}
